/**
 * create time:2013-12-15
 */
ReportTools =  {

	
	/**
	 * 
	 */
	"toggleIframe" : function(divid,iframeSrc) {
		var div = document.getElementById(divid);
		if(!div){
			this.consoleLog("get div error!divid=" + divid);
			return ;
		}

//		var iframeSrc = 'http://www.yy.com';
		
		if(div.style.display=="block"){
			div.style.display="none";
		}else{
			div.style.display="block";
			var iframeHtml='<iframe '
				+'style="width:100%;height: 100%;frameborder:no; border:0; padding:0; margin:0;" '
				+'src="' + iframeSrc + '" ' 
				+'onload="ReportTools.resizeIframe(this)">' 
				+ '</iframe>'
				; 
			div.innerHTML=iframeHtml;
		}
		
	},	
	
	"resizeIframe":function (obj){
		obj.height=obj.contentWindow.document.documentElement.scrollHeight;
		obj.width=obj.contentWindow.document.documentElement.scrollWidth;
		var parentNode = obj.parentNode;
		
		parentNode.style.height=obj.contentWindow.document.documentElement.scrollHeight + "px";
		parentNode.style.width=obj.contentWindow.document.documentElement.scrollWidth + "px";
		
		parent.document.all.mainFrame.height = parent.document.all.mainFrame.contentWindow.document.documentElement.scrollHeight;
		
	},
	
	"suitableIframe":function(){
		parent.document.all.mainFrame.height = parent.document.all.mainFrame.contentWindow.document.documentElement.scrollHeight;
		parent.document.all.mainFrame.width = parent.document.all.mainFrame.contentWindow.document.documentElement.scrollWidth;
	},
	
	"resizeMainIframe":function (divId){
		var tabid = '#'+divId ; 
		//var div = document.getElementById(divId);
		var mainFrame = top.document.getElementById('mainFrame');
		$(tabid).ready(function(){
			mainFrame.height = $(tabid).height()+400;
			//mainFrame.width = $(tabid).width()+100;
		});
	},
	
	"hiddenDiv":function (obj){
		var div = document.getElementById(obj);
		
		if(div.style.display=="block"){
			div.style.display="none";
		}
	},
	
	"reportAuditLog":function (userName,method,methodGroup){
		var projectName = "产品分析系统";
		var src = "http://auditlog.game.yy.com/rpc/AuditLogWebService/createAuditLog?projectName="+projectName+"&userName="+userName+"&method="+method+"&methodGroup="+methodGroup ; 
		this.newImage(src) ; 
	},
	
	/**
	 * 创建一个1像素的image ，并设置其src 。 
	 * @return Image
	 * @since 1.3.0
	 */
	"newImage":function (url){
		var image = new Image(1, 1);
        image.src = url;
        return image ; 
	},	
	
	"toggle":function (targetid,desc,divid){
		target=document.getElementById(targetid);
		if(target.style.display=="block"){
			target.style.display="none";
			var iHtml = "<strong>"+desc+"</strong><i class='icon-arrow-down'>";
			document.getElementById(divid).innerHTML=iHtml;
		}else{
			target.style.display="block";
			document.getElementById(divid).innerHTML="<strong>收起</strong><i class='icon-arrow-up'>";
		}
		parent.document.all.mainFrame.height = parent.document.all.mainFrame.contentWindow.document.documentElement.scrollHeight;
	},
	
	/**
	 * obj:select name
	 * index:the option index to remove
	 */
	"removeOption" : function(obj,index){
		$("select[name="+obj+"]").find("option:eq("+index+")").remove();
	},
	
	/**
	 * obj:select id
	 * index:the option index to remove
	 */
	"removeSelectOption" : function(obj,index){
		var select = document.getElementById(obj);
		select.options.remove(index);
	},
	
	/**
	 * print log to console 
	 */
	"consoleLog" : function (msg) {  
	  try {  
	  	if(this.__debug){
	    	console.log(new Date().getTime()+ " - " + msg);
	  	}  
	  } catch (e) {  
	    // not support console method (ex: IE)   
	  }
	},
	
	"end" : ""
	
} ;	